import {RequestAxios} from "../utils/request"
import type {
  LoginUserParams,
  LoginUserResult,
  SendCodeParams,
  UploadAvatarResult,
  UserCountsResult,
  UserInfoParams,
  UserInfoResult,
} from "../types/user.d"

export const sendCodeAPI = (data: SendCodeParams) =>
  RequestAxios.post("/user/login", data)

export const loginUserAPI = (data: LoginUserParams) =>
  RequestAxios.post<LoginUserResult>("/user/loginVerification", data)

export const uploadAvatarAPI = (data: FormData) =>
  RequestAxios.post<UploadAvatarResult>("/user/loginReginfo/head", data, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  })

export const saveUserAPI = (data: UserInfoParams) =>
  RequestAxios.post("/user/loginReginfo", data)

export const getUserInfoAPI = () =>
  RequestAxios.get<UserInfoResult>("/my/userinfo")

export const getUserCountsAPI = () =>
  RequestAxios.get<UserCountsResult>("/my/counts")
